﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="closure.aspx.cs" Inherits="closure" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta charset="utf-8" />
    <title>闭包演示</title>
    <style type="text/css">
        p
        {
            background: gold;
        }
    </style>
    <script type="text/javascript">
        function init() {
            var pAry = document.getElementsByTagName("p");
            for (var i = 0; i < pAry.length; i++) {
                pAry[i].onclick = function (num) {
                    return function () {
                        alert(num);
                    }
                } (i);
            }
        }
//        function aa() {
//            alert("bb");
//        }

//        alert(aa());
    </script>
</head>
<body onload="init();">
    <p>
        产品 0</p>
    <p>
        产品 1</p>
    <p>
        产品 2</p>
    <p>
        产品 3</p>
    <p>
        产品 4</p>
</body>
</html>
